﻿using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Sys;
using Rhonin.Common.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.Mongo.Sys.Impl
{
    [Component(LifeStyle.Singleton)]
    public class SysMenuQueryService : ISysMenuQueryService
    {
        private readonly ISysRepository<SysMenu> _sysMenuRepository;
        public SysMenuQueryService(ISysRepository<SysMenu> sysMenuRepository)
        {
            _sysMenuRepository = sysMenuRepository;
        }

        public SysMenu Get(Expression<Func<SysMenu, bool>> where)
        {
            return _sysMenuRepository.GetQuery().FirstOrDefault(where);
        }

        public List<SysMenu> GetList(Expression<Func<SysMenu, bool>> where)
        {
            return _sysMenuRepository.GetQuery().Where(where).ToList();
        }
    }
}
